Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2283 - Chat should not replace symbols in <code> #2293

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

SebinSong
Copy link
Collaborator

@SebinSong SebinSong commented Aug 8, 2024

closes #2283

[Proof of the fix]

@SebinSong SebinSong self-assigned this Aug 8, 2024
Copy link

cypress bot commented Aug 8, 2024



Test summary

112 0 10 0


Run details

Project group-income
Status Passed
Commit 2ecd91f ℹ️
Started Aug 8, 2024 11:46 PM
Ended Aug 8, 2024 11:56 PM
Duration 10:33 💡
OS Linux Ubuntu - 20.04
Browser Electron 89

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

Comment on lines +36 to +50
const strSplitByCodeMarkdown = splitStringByMarkdownCode(str)
strSplitByCodeMarkdown.forEach((entry, index) => {
if (entry.type === 'plain' && strSplitByCodeMarkdown[index - 1]?.text !== '```') {
let entryText = entry.text
entryText = entryText.replace(/</g, '&lt;').replace(/>/g, '&gt;')

str = str.replace(/\n(?=\n)/g, '\n<br>')
.replace(/<br>\n(\s*)(\d+\.|-|```)/g, '\n\n$1$2') // custom-handling the case where <br> is directly followed by the start of block-code (```)
.replace(/(\d+\.|-)(\s.+)\n<br>/g, '$1$2\n\n') // this is a custom-logic added so that the end of ordered/un-ordered lists are correctly detected by markedjs.
entryText = entryText.replace(/\n(?=\n)/g, '\n<br>')
.replace(/<br>\n(\s*)(\d+\.|-)/g, '\n\n$1$2') // custom-handling the case where <br> is directly followed by the start of ordered/unordered lists
.replace(/(\d+\.|-)(\s.+)\n<br>/g, '$1$2\n\n') // this is a custom-logic added so that the end of ordered/un-ordered lists are correctly detected by markedjs.

entry.text = entryText
}
})

str = combineMarkdownSegmentListIntoString(strSplitByCodeMarkdown)
Copy link
Collaborator Author

@SebinSong SebinSong Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cause of the issue was that,
These additional fixes & adjustments related to white-spaces, line-breaks and < and > did not need to be applied to the contents of <code>...</code>.
So a logic added here where it selectively apply these adjustments to the text contents outside of <code>...</code>.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

@taoeffect taoeffect merged commit a1bf62c into master Aug 14, 2024
4 checks passed
@taoeffect taoeffect deleted the sebin/task/#2283-bug-in-markdown branch August 14, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chat should not replace symbols in <code> (aka <pre>) tags
2 participants